package com.guoguo.api;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.guoguo.base.BaseController;
import com.guoguo.entity.UserExt;
import com.guoguo.service.IUserExtService;
import com.guoguo.service.UploadService;

/**
 * Created by Administrator on 2017/10/26 0026.
 */

     /*
                           _ooOoo_
                          o8888888o
                          88" . "88
                          (| -_- |)
                          O\  =  /O
                       ____/`---'\____
                     .'  \\|     |//  `.
                    /  \\|||  :  |||//  \
                   /  _||||| -:- |||||-  \
                   |   | \\\  -  /// |   |
                   | \_|  ''\---/''  |   |
                   \  .-\__  `-`  ___/-. /
                 ___`. .'  /--.--\  `. . __
              ."" '<  `.___\_<|>_/___.'  >'"".
             | | :  `- \`.;`\ _ /`;.`/ - ` : | |
             \  \ `-.   \_ __\ /__ _/   .-` /  /
        ======`-.____`-.___\_____/___.-`____.-'======
                           `=---='
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                 佛祖保佑       永无BUG
        */
@RestController
@RequestMapping("/api/test")
public class TestController extends BaseController {

    @Resource
    private IUserExtService userExtService;

    @Resource
    private UploadService uploadService;

    /**
     * 查询用户信息
     *
     * @return
     * @throws Exception 
     */
    @ResponseBody
    @RequestMapping(value = "/testUser", method = RequestMethod.POST)
    public JSONObject findUser() throws Exception {
        List<UserExt> userExtList = userExtService.selectUserExt();
        for (UserExt userExt : userExtList) {
            String qrcodeUrl = uploadService.uploadQRCode(userExt.getUserId(), "");
            userExt.setQrcode(qrcodeUrl);
            userExtService.updateUserExt(userExt);
        }
        return null;
    }
}
